package algorithm;


/**
 * @description: 冒泡算法
 * @author: TanJingyu
 * @create: 2023-02-07 10:54
 **/
public class BubblingAlgorithm {
    private static final int[] array = new int[]{4,5,2,3,8,6,1,45,8,73,2};

    public static void main(String[] args) {
        int k;
        for (int i = 0; i < array.length; i++) {
            int min = array[i];
            for (int j = i + 1; j < array.length; j++) {
                if (min > array[j]) {
                    k = min;
                    min = array[j];
                    array[j] = k;
                }
            }
            array[i] = min;
        }
        for (int i : array) {
            System.out.println(i);
        }
    }
}

    